<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

	function _initAuthentication()
	{
		$acl = new Application_Model_AclLibrary();

		$auth = Zend_Auth::getInstance();

		$frontController = Zend_Controller_Front::getInstance();
		$frontController->registerPlugin(new Application_Plugin_AccessCheck($acl, $auth));
	}


	function _initViewHelpers()
	{
		$this->bootstrap('layout');
		$layout = $this->getResource('layout');
		$view = $layout->getView();
		$view->setEncoding('UTF-8');

		$view->doctype('XHTML1_STRICT');
		$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
		$view->headLink()->appendStylesheet('http://defmmdb01/css/main.css');
		$view->headLink()->appendStylesheet('http://defmmdb01/css/smoothness/jquery-ui-1.8.21.custom.css');
		$view->headTitle()->setSeparator(' - ');
		$view->headTitle('Business Intelligence System');
		
		
		$view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
		$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
		$viewRenderer->setView($view);
		Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
	}

	function _initNavigation()
	{

		$this->bootstrap('layout');
		$layout = $this->getResource('layout');
		$view = $layout->getView();

		$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml','nav');
		$navigation = new Zend_Navigation($config);


		$view->navigation($navigation);

		$acl = new Application_Model_AclLibrary();

		if(Zend_Auth::getInstance()->hasIdentity()) {
			$role = Zend_Auth::getInstance()->getIdentity()->userrole;
			$view->navigation($navigation)->setAcl($acl)->setRole($role);
		}



	}

}

